<template>
  <div class="base-echart">
    <div
      ref="echartDivRef"
      :style="{
        width: width,
        height: height,
      }"
    ></div>
  </div>
</template>

<script setup>
import { withDefaults, defineProps, ref, onMounted, watchEffect } from "vue";
import useEchart from "../hooks/useEchart";
import "../data/china.json";

const props = defineProps({
  options: Object,
  width: {
    type: String,
    default: "100%",
  },
  height: {
    type: String,
    default: "360px",
  },
});

const echartDivRef = ref();

onMounted(() => {
  const { setOptions } = useEchart(echartDivRef.value);

  watchEffect(() => {
    setOptions(props.options);
  });
});
</script>

<style lang="less" scoped></style>
